package com.ecp.base.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ecp.base.bean.SystemArgument;
import com.ecp.base.dao.SystemArgumentDAO;
import com.ecp.commons.db.GenericServiceImpl;

@Repository("systemArgumentService")
public class SystemArgumentServiceImpl extends GenericServiceImpl<SystemArgument> implements SystemArgumentService {

	@Autowired
	private SystemArgumentDAO	systemArgumentDAO;

	@Override
	public SystemArgument getValueByArgKey(String string) throws Exception {
		String sql = "SELECT * FROM t_sys_arguments WHERE argkey=?;";
		return systemArgumentDAO.getEntity(sql, new Object[] { string }, new SystemArgument());
	}

	@Override
	public String getStringValueByArgKey(String string) throws Exception {
		String sql = "SELECT * FROM t_sys_arguments WHERE upper(ArgKey)=?;";
		SystemArgument systemArgument = systemArgumentDAO.getEntity(sql, new Object[] { string.toUpperCase() },
				new SystemArgument());
		if (systemArgument != null) {
			return systemArgument.getArgValue();
		} else {
			return "";
		}
	}

}
